using SuperSocket;
using SuperSocket.Command;
using SuperSocket.ProtoBase;
using SuperSocket.WebSocket.Server;
using WebSocketServerAspCoreApi;
using WebSocketServerAspCoreApi.Commands;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Host.AsWebSocketHostBuilder()
            .ConfigureAppConfiguration((hostCtx, configApp) =>
            {
                configApp.AddInMemoryCollection(new Dictionary<string, string?>
                {
                    { "serverOptions:name", "TestServer" },
                    { "serverOptions:listeners:0:ip", "Any" },
                    { "serverOptions:listeners:0:port", "4040" }
                });
            })
            .UseCommand<StringPackageInfo, StringPackageConverter>(commandOptions => commandOptions.AddCommand<ADD>())
            .UsePerMessageCompression()
            .UseInProcSessionContainer()
            .AsMinimalApiHostBuilder()
            .ConfigureHostBuilder();

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseAuthorization();

app.MapControllers();

app.Run();
